import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:pornhub_app/views/mine/frontpage/controller/mine_setting_controller.dart';

import '../../../assets/styles.dart';
import '../../../utils/color.dart';

class SettingPage extends StatelessWidget {
  const SettingPage({super.key});

  @override
  Widget build(BuildContext context) {
    final bgColor = Styles.color.bgColor;

    return Scaffold(
      backgroundColor: bgColor,
      appBar: AppBar(
        iconTheme: const IconThemeData(color: Colors.white),
        title: Text("设置",
            textAlign: TextAlign.center,
            style: TextStyle(
              color: COLOR.hexColor('#ffffff'),
              fontSize: 16.w,
              fontWeight: FontWeight.w600,
            )),
        centerTitle: true,
      ),
      body: const SettingPageChild(),
    );
  }
}

class SettingPageChild extends StatefulWidget {
  const SettingPageChild({super.key});

  @override
  State<StatefulWidget> createState() => SettingPageChildState();
}

class SettingPageChildState extends State<SettingPageChild> {
  final controller = Get.find<MineSettingController>();

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.maxFinite,
      margin: EdgeInsets.symmetric(horizontal: 14.w, vertical: 16.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Flex(
            direction: Axis.horizontal,
            children: [
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '应用锁开关',
                      style: TextStyle(
                        fontSize: 14.w,
                        color: COLOR.hexColor('#ffffff'),
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    InkWell(
                      onTap: () => controller.onClick(4),
                      child: Text(
                        '设置/修改密码>>',
                        style: TextStyle(
                          fontSize: 14.w,
                          color: COLOR.playerThemColor,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              // InkWell(
              //   onTap: () {
              //     controller.onClick(1);
              //     setState(() {});
              //   },
              //   child: Obx(() => Image.asset(
              //         controller.isAppLock.value
              //             ? 'assets/mine/img_switch_select.png'
              //             : 'assets/mine/img_switch_normal.png',
              //         width: 54.w,
              //         height: 25.w,
              //       )),
              // ),
            ],
          ),
          Padding(padding: EdgeInsets.only(top: 25.w)),
          Visibility(
              visible: GetPlatform.isAndroid,
              child: Column(
                children: [
                  Flex(
                    direction: Axis.horizontal,
                    children: [
                      Expanded(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              '设置桌面隐私图标',
                              style: TextStyle(
                                fontSize: 14.w,
                                color: COLOR.hexColor('#ffffff'),
                                fontWeight: FontWeight.w600,
                              ),
                            ),
                            InkWell(
                              onTap: () => controller.onClick(5),
                              child: Text(
                                '更换图标>>',
                                style: TextStyle(
                                  fontSize: 14.w,
                                  color: COLOR.playerThemColor,
                                  fontWeight: FontWeight.w600,
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      // InkWell(
                      //   onTap: () {
                      //     controller.onClick(2);
                      //     setState(() {});
                      //   },
                      //   child: Image.asset(
                      //     controller.service.isChangeAppIcon
                      //         ? 'assets/mine/img_switch_select.png'
                      //         : 'assets/mine/img_switch_normal.png',
                      //     width: 54.w,
                      //     height: 25.w,
                      //   ),
                      // ),
                    ],
                  ),
                  Padding(padding: EdgeInsets.only(top: 25.w)),
                  InkWell(
                    highlightColor: Styles.color.bgColor,
                    splashColor: Styles.color.bgColor,
                    onTap: () {
                      controller.onClick(6);
                    },
                    child: Flex(
                      direction: Axis.horizontal,
                      children: [
                        Expanded(
                          child: Text(
                            '我的账号卡',
                            style: TextStyle(
                              fontSize: 14.w,
                              color: COLOR.hexColor('#ffffff'),
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                        ),
                        Text(
                          '>',
                          style: TextStyle(
                            fontSize: 14.w,
                            color: COLOR.hexColor('#999999'),
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Padding(padding: EdgeInsets.only(top: 25.w)),
                  InkWell(
                    onTap: () {
                      controller.onClick(3);
                      setState(() {});
                    },
                    child: Flex(
                      direction: Axis.horizontal,
                      children: [
                        Expanded(
                          child: Text(
                            '清理缓存',
                            style: TextStyle(
                              fontSize: 14.w,
                              color: COLOR.hexColor('#ffffff'),
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                        ),
                        Obx(
                          () => Text(
                            controller.imageCachesize.value,
                            style: TextStyle(
                              fontSize: 14.w,
                              color: COLOR.playerThemColor,
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                        ),
                        Padding(padding: EdgeInsets.only(left: 5.w)),
                        Text(
                          '>',
                          style: TextStyle(
                            fontSize: 14.w,
                            color: COLOR.hexColor('#999999'),
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Padding(padding: EdgeInsets.only(top: 25.w)),
                  Flex(
                    direction: Axis.horizontal,
                    children: [
                      Expanded(
                        child: Text(
                          '版本号',
                          style: TextStyle(
                            fontSize: 14.w,
                            color: COLOR.hexColor('#ffffff'),
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ),
                      Obx(() => Text(
                            '当前版本号${controller.version.value}',
                            style: TextStyle(
                              fontSize: 14.w,
                              color: COLOR.playerThemColor,
                              fontWeight: FontWeight.w600,
                            ),
                          )),
                      Padding(padding: EdgeInsets.only(left: 5.w)),
                      Text(
                        '>',
                        style: TextStyle(
                          fontSize: 14.w,
                          color: COLOR.hexColor('#999999'),
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ],
                  ),
                ],
              )),
        ],
      ),
    );
  }
}
